package cn.djjboom.deepinspringboot.bootstrap;

import cn.djjboom.deepinspringboot.condition.ConditionnalOnSystemProperty;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;

/**
 * @author djj
 * @Date 2019/9/5
 * @Time 下午10:21
 */

public class ConditionalOnSystemPropertyBootstrap {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = new SpringApplicationBuilder(ConditionalOnSystemPropertyBootstrap.class)
                .web(WebApplicationType.NONE)
                .run(args);
        String helloWorld = context.getBean("helloWorld", String.class);
        System.out.println("hello world : "+helloWorld);
        context.close();

    }

    @Bean
    @ConditionnalOnSystemProperty(name = "user.name",value = "djj")
    public String helloWorld(){
        return "hello world 2019";
    }
}
